//
//  encapsulated.hpp
//  learnC++
//
//  Created by apple on 2018/6/2.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef encapsulated_hpp
#define encapsulated_hpp

#include <stdio.h>
#include <iostream>
#include <array>

//封装思想

class IntArray2
{
private:
    int m_array[10]; // user can not access this directly any more
    int m_value1;
    
public:
    
    //用这种方式，防止外界直接调用m_array,也可以防止用户输入不正当的下标crash
    void setValue(int index, int value)
    {
        // If the index is invalid, do nothing
        if (index < 0 || index >= 10)
            return;
        
        m_array[index] = value;
    }
    
    //set、get方法
    void setvalue1(int value){
        m_value1 = value;
    }
    int getValue1(){
        return m_value1;
    }
};

#endif /* encapsulated_hpp */
